package com.ideaaedi.springcloud.jd.message.controller;

import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.req.MsgAuthInfoAddReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.req.MsgAuthInfoBatchAddReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.req.MsgAuthInfoListReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.req.MsgAuthInfoUpdateReqVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.resp.MsgAuthInfoBatchAddRespVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.resp.MsgAuthInfoDetailRespVO;
import com.ideaaedi.springcloud.jd.commonds.entity.message.vo.resp.MsgAuthInfoListRespVO;
import com.ideaaedi.springcloud.jd.message.service.MsgAuthInfoService;
import com.ideaaedi.springcloud.jd.commonds.entity.PageInfo;
import com.ideaaedi.springcloud.jd.commonds.entity.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * 消息-认证
 *
 * @author <font size = "20" color = "#3CAA3C"><a href="https://gitee.com/JustryDeng">JustryDeng</a></font> <img src="https://gitee.com/JustryDeng/shared-files/raw/master/JustryDeng/avatar.jpg" />
 * @since 2021.0.5.B
 */
@Validated
@RestController
@RequestMapping("/msg-auth-info")
@Api(value = "消息-认证", tags = {"消息-认证"})
public class MsgAuthInfoController {

    @Resource
    private MsgAuthInfoService msgAuthInfoService;

    /**
     * 增
     *
     * @param req 参数
     *
     * @return 新增的数据详情
     */
    @ApiOperation("增")
    @PostMapping("/add")
    public Result<MsgAuthInfoDetailRespVO> add(@RequestBody @Validated MsgAuthInfoAddReqVO req) {
        return Result.success(msgAuthInfoService.add(req, true));
    }

    /**
     * 批量增
     *
     * @param req 参数
     *
     * @return MsgAuthInfoBatchAddRespVO
     */
    @ApiOperation("批量增")
    @PostMapping("/batch-add")
    public Result<MsgAuthInfoBatchAddRespVO> batchAdd(@RequestBody @Validated MsgAuthInfoBatchAddReqVO req) {
        return Result.success(msgAuthInfoService.batchAdd(req));
    }

    /**
     * 删
     *
     * @param id 要删除数据的id
     *
     * @return 删除了的数据详情
     */
    @ApiOperation("删")
    @DeleteMapping("/delete/{id}")
    public Result<MsgAuthInfoDetailRespVO> delete(@ApiParam(value = "要删除数据的id", required = true)
                                            @PathVariable("id") @NotNull(message = "id cannot be null.") Long id) {
        return Result.success(msgAuthInfoService.delete(id));
    }

    /**
     * 改
     *
     * @param req 参数
     *
     * @return 修改后的数据详情
     */
    @ApiOperation("改")
    @PutMapping("/update")
    public Result<MsgAuthInfoDetailRespVO> update(@RequestBody @Validated MsgAuthInfoUpdateReqVO req) {
        return Result.success(msgAuthInfoService.update(req));
    }

    /**
     * 查详情
     *
     * @param id 要查询数据的id
     *
     * @return 数据详情
     */
    @ApiOperation("查详情")
    @GetMapping("/detail/{id}")
    public Result<MsgAuthInfoDetailRespVO> detail(@ApiParam(value = "要查询数据的id", required = true)
                                            @PathVariable("id") @NotNull(message = "id cannot be null.") Long id) {
        return Result.success(msgAuthInfoService.detail(id));
    }

    /**
     * 查列表
     *
     * @param req 参数
     *
     * @return 数据列表
     */
    @PostMapping("/list")
    @ApiOperation("查列表")
    public Result<PageInfo<MsgAuthInfoListRespVO>> list(@RequestBody @Validated MsgAuthInfoListReqVO req) {
        return Result.success(msgAuthInfoService.list(req));
    }

}
